
/**
 * 将json对象uri化。
 * 示例：var foo1=uriJson(jsonForm('form1',{elem:['select','textarea']}));//可将id改为对象
 * @param o
 * @returns
 */
function uriJson(o){
    if(!o||'object'!==typeof(o))return;
    var a=[],A=arguments;
    for(var z in o){
        if(null===o[z]){
            a.push(encodeURIComponent(z) +'=');
            continue;
        }
        if(isArray(o[z])){
            for(var x=0,L=o[z].length;x<L;x++){
                if(typeof(o[z][x])=='object'){
                    a.push(A.callee(o[z][x]));
                }else{
                    a.push(encodeURIComponent(z +'[]') +'='+ encodeURIComponent(o[z][x]));
                }
            }
        }else if(o[z]&&typeof(o[z])=='object'){
            a.push(A.callee(o[z]));
        }else if(typeof(o[z])=='function'){
                continue;
        }else{
            a.push(encodeURIComponent(z) +'='+ encodeURIComponent(o[z]));
        }
    }
return a.join('&').replace(/%20/g, '+');
}

//创建过滤规则数据(查询表单)
function bulidFilterParams(form){
	if (!form) return null;
	var params = new Map();
    $(":input", form).not(":submit, :reset, :image,:button, [disabled]").each(function ()
    {
        if (!this.name) return;
        if (!$(this).hasClass("field")) return;
        if ($(this).val() == null || $(this).val() == "") return;
        var ltype = $(this).attr("ltype");
        var optionsJSON = $(this).attr("ligerui"), options;
        if (optionsJSON)
        {
            options = JSON2.parse(optionsJSON);
        }
        var value = $(this).val();
        var name = this.name;
        //如果是下拉框，那么读取下拉框关联的隐藏控件的值(ID值,常用与外表关联)
        if (ltype == "select" && options && options.valueFieldID)
        {
            value = $("#" + options.valueFieldID).val();
            name = options.valueFieldID;
        }
        params.put(name,value);
    });
    return params.toJson();
};

function inArray(v,a,s){
    if(!isArray(a)||a.length==0)return false;
    var eq=(function(){
        if(s)return function(x,y){return x===y;};
        else return function(x,y){return x==y;};
    })();
    if(typeof(v)=='string'||typeof(v)=='number'){
        for(var z=0,L=a.length;z<L;z++){
            if(eq(a[z],v))return true;
        }
    }
return false;
}

function isArray(a){
    if(!a)return false;
    return (typeof a != "undefined" ? a.constructor == Array : typeof a.length != "undefined");
}

function ext$(o,O,s){
    if('object'!=typeof(o)||'object'!=typeof(O)||!o||!O)return o;
    if(s){
        for(var z in o){
            if(O.hasOwnProperty(z))
                o[z]=O[z];
        }
    }else{
        for(var z in O){
            o[z]=O[z];
        }
    }
return o;
}